{{include_file name='home/public/header' title='接口字段'}}
<style>
    .table>thead>tr>th, .table>tbody>tr>th, .table>tfoot>tr>th, .table>thead>tr>td, .table>tbody>tr>td, .table>tfoot>tr>td {
        padding: 8px 8px 8px 0;
        line-height: 1.42857143;
        vertical-align: top;
        border-top: 1px solid #ddd;
    }
    .table>tbody>tr.level1>td, .table>tbody>tr.level1>th, .table>tbody>tr>td.level1, .table>tbody>tr>th.level1, .table>tfoot>tr.level1>td, .table>tfoot>tr.level1>th, .table>tfoot>tr>td.level1, .table>tfoot>tr>th.level1, .table>thead>tr.level1>td, .table>thead>tr.level1>th, .table>thead>tr>td.level1, .table>thead>tr>th.level1 {
        background-color: #f5f5f5;
    }
    .table>tbody>tr.level2>td, .table>tbody>tr.level2>th, .table>tbody>tr>td.level2, .table>tbody>tr>th.level2, .table>tfoot>tr.level2>td, .table>tfoot>tr.level2>th, .table>tfoot>tr>td.level2, .table>tfoot>tr>th.level2, .table>thead>tr.level2>td, .table>thead>tr.level2>th, .table>thead>tr>td.level2, .table>thead>tr>th.level2 {
        background-color: rgba(255,255,255,.15);
    }
</style>

</head>

<body>

<div id="wrapper">

    <!-- Navigation -->
    {{include_file name='home/public/nav' sidebar='home/project/sidebar'}}
    <div id="page-wrapper">

        <div class="row">
            <div class="col-lg-12">
                <div class="page-header">
                    <h1>接口字段 </h1>
                    <div class="opt-btn">

                        {{if $project->hasAuth(['api' => 'update'])}}
                            {{if $field->id}}
                            <a href="{{url('home/field/update', ['id' => $field->encode_id])}}" class="btn btn-sm hidden-xs btn-warning"><i class="fa fa-fw fa-edit"></i>编辑</a>
                            {{else}}
                            <a href="{{url('home/field/create', ['api_id' => $api->encode_id])}}" class="btn btn-sm hidden-xs btn-success"><i class="fa fa-fw fa-edit"></i>添加</a>
                            {{/if}}
                        {{/if}}

                    </div>
                </div>
            </div>
            <!-- /.col-lg-12 -->
        </div>

        <!-- 接口详情 -->
        <div class="row">
            <div class="col-lg-12">
                <div class="panel panel-default">

                    {{include_file name='home/api/tab' tab='field'}}

                    <div class="panel-body">
                        <!--header参数-->
                        {{if isset($field->headerAttributes)}}
                        <div class="row">
                            <div class="col-lg-12">
                                <div class="panel panel-default">
                                    <div class="panel-heading">
                                        Header参数
                                    </div>
                                    <!-- /.panel-heading -->
                                    <div class="panel-body">
                                        <div class="table-responsive">
                                            <table class="table">
                                                <thead>
                                                <tr>
                                                    <th width="200px">参数名</th>
                                                    <th width="200px">参数标题</th>
                                                    <th width="100px">参数类型</th>
                                                    <th width="60px">必填</th>
                                                    <th width="90px">参数值</th>
                                                    <th>备注说明</th>
                                                </tr>
                                                </thead>
                                                <tbody>
                                                {{foreach $field->headerAttributes as $header}}
                                                <tr class="level{{$header->level}}">
                                                    <td>
                                                        {{if $header->level}}
                                                        {{str_repeat('&nbsp;&nbsp;&nbsp;', $header->level)}}
                                                        <i class="fa fa-fw fa-angle-right fa-1" aria-hidden="true"></i>
                                                        {{/if}}
                                                        {{$header->name}}
                                                    </td>
                                                    <td>{{$header->title}}</td>

                                                    <td>{{$field->fieldTypeLabels[$header->type]}}</td>
                                                    <td>{{$field->requiredLabels[$header->required]}}</td>

                                                    <td>{{$header->value}}</td>
                                                    <td>{{$header->remark}}</td>
                                                </tr>
                                                {{/foreach}}

                                                </tbody>
                                            </table>
                                        </div>
                                        <!-- /.table-responsive -->
                                    </div>
                                    <!-- /.panel-body -->
                                </div>
                                <!-- /.panel -->
                            </div>
                            <!-- /.col-lg-6 -->
                        </div>
                        {{/if}}
                        <!--请求参数-->
                        <div class="row">
                            <div class="col-lg-12">
                                <div class="panel panel-default">
                                    <div class="panel-heading">
                                        请求参数
                                    </div>
                                    <!-- /.panel-heading -->
                                    <div class="panel-body">
                                        <div class="table-responsive">
                                            <table class="table">
                                                <thead>
                                                <tr>
                                                    <th width="200px">参数名</th>
                                                    <th width="200px">参数标题</th>
                                                    <th width="100px">参数类型</th>
                                                    <th width="60px">必填</th>
                                                    <th width="90px">示例值</th>
                                                    <th>备注说明</th>
                                                </tr>
                                                </thead>
                                                <tbody>
                                                {{foreach $field->requestAttributes as $request}}
                                                <tr class="level{{$request->level}}">
                                                    <td>
                                                        {{if $request->level}}
                                                        {{str_repeat('&nbsp;&nbsp;&nbsp;', $request->level)}}
                                                        <i class="fa fa-fw fa-angle-right fa-1" aria-hidden="true"></i>
                                                        {{/if}}
                                                        {{$request->name}}
                                                    </td>

                                                    <td>{{$request->title}}</td>
                                                    <td>{{$field->fieldTypeLabels[$request->type]}}</td>
                                                    <td>{{$field->requiredLabels[$request->required]}}</td>
                                                    <td>{{$request->example_value}}</td>
                                                    <td>{{$request->remark}}</td>
                                                </tr>
                                                {{/foreach}}
                                                </tbody>
                                            </table>
                                        </div>
                                        <!-- /.table-responsive -->
                                    </div>
                                    <!-- /.panel-body -->
                                </div>
                                <!-- /.panel -->
                            </div>
                            <!-- /.col-lg-6 -->
                        </div>
                        <!--响应参数-->
                        <div class="row">
                            <div class="col-lg-12">
                                <div class="panel panel-default mb-0">
                                    <div class="panel-heading">
                                        响应参数
                                    </div>
                                    <!-- /.panel-heading -->
                                    <div class="panel-body">
                                        <div class="table-responsive">
                                            <table class="table">
                                                <thead>
                                                <tr>
                                                    <th width="200px">参数名</th>
                                                    <th width="200px">参数标题</th>
                                                    <th width="100px">参数类型</th>
                                                    <th width="150px">示例值</th>
                                                    <th>备注说明</th>
                                                </tr>
                                                </thead>
                                                <tbody>
                                                {{foreach $field->responseAttributes as $response}}
                                                <tr class="level{{$response->level}}">
                                                    <td>
                                                        {{if $response->level}}
                                                        {{str_repeat('&nbsp;&nbsp;&nbsp;', $response->level)}}
                                                        <i class="fa fa-fw fa-angle-right fa-1" aria-hidden="true"></i>
                                                        {{/if}}
                                                        {{$response->name}}
                                                    </td>
                                                    <td>{{$response->title}}</td>
                                                    <td>{{$field->fieldTypeLabels[$response->type]}}</td>
                                                    <td>{{$response->example_value}}</td>
                                                    <td>{{$response->remark}}</td>
                                                </tr>
                                                {{/foreach}}
                                                </tbody>
                                            </table>
                                        </div>
                                        <!-- /.table-responsive -->
                                    </div>
                                    <!-- /.panel-body -->
                                </div>
                                <!-- /.panel -->
                            </div>
                            <!-- /.col-lg-6 -->
                        </div>

                    </div>

                </div>

            </div>

        </div>

    </div>
    <!-- /#page-wrapper -->

</div>

<!-- /#wrapper -->
{{include_file name='home/public/copyright'}}

<script>
$(function () {

    // 未设置环境弹框提示
    {{if $project->getEnvs()->count() == 0}}
    confirm('项目至少需要设置一个环境，请立即设置', function(){
        window.location.href = "{{url('project/show', ['id' => $project->encode_id, 'tab' => 'env'])}}";
    });
    {{/if}}

});
</script>

{{include_file name='home/public/footer'}}